<!DOCTYPE html>
<html>
<head>
    

    

    


<!-- Baidu Push -->
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
<!-- End Baidu Push -->


    <meta charset="utf-8">
    
    
    
    <title>Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1 | JK客栈 | 王怀亮的博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="阿里云,Linux,CentOS,Redis,安装,4.0.1">
    <meta name="description" content="本文介绍如何在 Linux CentOS 7.3 上安装 Redis 4.0.1，及安装过程中常见问题的解决">
<meta name="keywords" content="Redis">
<meta property="og:type" content="article">
<meta property="og:title" content="Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1">
<meta property="og:url" content="http://www.jkinn.com/2017/08/16/20170816001/index.html">
<meta property="og:site_name" content="JK客栈">
<meta property="og:description" content="本文介绍如何在 Linux CentOS 7.3 上安装 Redis 4.0.1，及安装过程中常见问题的解决">
<meta property="og:updated_time" content="2017-08-16T11:32:36.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1">
<meta name="twitter:description" content="本文介绍如何在 Linux CentOS 7.3 上安装 Redis 4.0.1，及安装过程中常见问题的解决">
    
        <link rel="alternate" type="application/atom+xml" title="JK客栈" href="/atom.xml">
    
    <link rel="shortcut icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">田埂↑の夢</h5>
          <a href="mailto:sdwanghuailiang@163.com" title="sdwanghuailiang@163.com" class="mail">sdwanghuailiang@163.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                分类
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/sdwanghuailiang" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://www.weibo.com/sdwanghuailiang" target="_blank" >
                <i class="icon icon-lg icon-weibo"></i>
                微博
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://www.dongchunlin.com"  >
                <i class="icon icon-lg icon-link"></i>
                小董董
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-08-16T11:32:29.000Z" itemprop="datePublished" class="page-time">
  2017-08-16
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/Redis/">Redis</a></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#Redis简介"><span class="post-toc-number">1.</span> <span class="post-toc-text">Redis简介</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#Redis-4-0-新特性"><span class="post-toc-number">2.</span> <span class="post-toc-text">Redis 4.0 新特性</span></a></li><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#Redis-4-0-1-安装"><span class="post-toc-number">3.</span> <span class="post-toc-text">Redis 4.0.1 安装</span></a></li></ol>
        </nav>
    </aside>
    
<article id="post-20170816001"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1</h1>
        <div class="post-meta">
            <time class="post-time" title="2017-08-16 19:32:29" datetime="2017-08-16T11:32:29.000Z"  itemprop="datePublished">2017-08-16</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/Redis/">Redis</a></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h1 id="Redis简介"><a href="#Redis简介" class="headerlink" title="Redis简介"></a>Redis简介</h1><p>Redis 是完全开源免费的，是一个高性能的key-value数据库。<br>Redis 与其他 key - value 缓存产品有以下三个特点：<br>Redis支持数据的持久化，可以将内存中的数据保存在磁盘中，重启的时候可以再次加载进行使用。<br>Redis不仅仅支持简单的key-value类型的数据，同时还提供list，set，zset，hash等数据结构的存储。<br>Redis支持数据的备份，即master-slave模式的数据备份。<br>性能极高 – Redis能读的速度是110000次/s,写的速度是81000次/s。</p>
<h1 id="Redis-4-0-新特性"><a href="#Redis-4-0-新特性" class="headerlink" title="Redis 4.0 新特性"></a>Redis 4.0 新特性</h1><p>Redis 4.x 相比 Redis 之前的版本，功能上有了很多改进，具体可参考以下几篇文章：</p>
<ul>
<li><a href="http://blog.huangz.me/diary/2016/redis-4-outline.html" target="_blank" rel="external">http://blog.huangz.me/diary/2016/redis-4-outline.html</a></li>
<li><a href="https://www.oschina.net/news/79619/redis-4-0-rc1" target="_blank" rel="external">https://www.oschina.net/news/79619/redis-4-0-rc1</a></li>
<li><a href="http://www.cnblogs.com/lshs/p/6195257.html" target="_blank" rel="external">http://www.cnblogs.com/lshs/p/6195257.html</a></li>
<li><a href="http://www.raincent.com/content-10-8073-1.html" target="_blank" rel="external">http://www.raincent.com/content-10-8073-1.html</a></li>
<li><a href="http://www.cnblogs.com/svan/p/7054129.html" target="_blank" rel="external">http://www.cnblogs.com/svan/p/7054129.html</a></li>
</ul>
<h1 id="Redis-4-0-1-安装"><a href="#Redis-4-0-1-安装" class="headerlink" title="Redis 4.0.1 安装"></a>Redis 4.0.1 安装</h1><p>本文以opt目录作为安装目录进行安装，详细安装过程如下：</p>
<ol>
<li><p>下载 Redis 4.0.1</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># cd /opt</span></div><div class="line">[root@localhost opt]<span class="comment"># wget http://download.redis.io/releases/redis-4.0.1.tar.gz</span></div></pre></td></tr></table></figure>
</li>
<li><p>解压 redis-4.0.1.tar.gz</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost opt]<span class="comment"># tar -zxvf redis-4.0.1.tar.gz</span></div></pre></td></tr></table></figure>
</li>
<li><p>编译<br>进入 redis 目录，执行 make 命令进行编译：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost opt]<span class="comment"># cd redis-4.0.1/</span></div><div class="line">[root@localhost redis-4.0.1]<span class="comment"># make</span></div></pre></td></tr></table></figure>
</li>
</ol>
<p>进行编译时，有可能会报如下两个错误：</p>
<ul>
<li>如果服务器未安装 gcc编译工具，则执行编译时，会报如下错误：<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">[root@localhost redis-4.0.1]<span class="comment"># make</span></div><div class="line">......</div><div class="line">......</div><div class="line">make[3]: gcc：命令未找到</div><div class="line">make[3]: *** [net.o] 错误 127</div><div class="line">make[3]: 离开目录“/opt/redis-4.0.1/deps/hiredis”</div><div class="line">make[2]: *** [hiredis] 错误 2</div><div class="line">make[2]: 离开目录“/opt/redis-4.0.1/deps”</div><div class="line">make[1]: [persist-settings] 错误 2 (忽略)</div><div class="line">    CC adlist.o</div><div class="line">/bin/sh: cc: 未找到命令</div><div class="line">make[1]: *** [adlist.o] 错误 127</div><div class="line">make[1]: 离开目录“/opt/redis-4.0.1/src”</div><div class="line">make: *** [all] 错误 2</div></pre></td></tr></table></figure>
</li>
</ul>
<p>此时，执行 yum install gcc 安装 gcc编译工具 即可：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">[root@localhost redis-4.0.1]<span class="comment"># yum install gcc</span></div><div class="line">......</div><div class="line">......</div><div class="line">已安装:</div><div class="line">  gcc.x86_64 0:4.8.5-11.el7                                                                                                                            </div><div class="line"></div><div class="line">作为依赖被安装:</div><div class="line">  glibc-devel.x86_64 0:2.17-157.el7_3.5                                     glibc-headers.x86_64 0:2.17-157.el7_3.5                                    </div><div class="line"></div><div class="line">作为依赖被升级:</div><div class="line">  glibc.x86_64 0:2.17-157.el7_3.5                                        glibc-common.x86_64 0:2.17-157.el7_3.5                                       </div><div class="line"></div><div class="line">完毕！</div></pre></td></tr></table></figure></p>
<ul>
<li>如果服务器没有安装 jemalloc，则会报如下错误：<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">......</div><div class="line">......</div><div class="line">In file included from adlist.c:34:0:</div><div class="line">zmalloc.h:50:31: 致命错误：jemalloc/jemalloc.h：没有那个文件或目录</div><div class="line"> <span class="comment">#include &lt;jemalloc/jemalloc.h&gt;</span></div><div class="line">                               ^</div><div class="line">编译中断。</div><div class="line">make[1]: *** [adlist.o] 错误 1</div><div class="line">make[1]: 离开目录“/opt/redis-4.0.1/src”</div><div class="line">make: *** [all] 错误 2</div></pre></td></tr></table></figure>
</li>
</ul>
<p>想要弄明白这个错误是怎么回事，我们得先看一下Redis的描述文档。打开Reids根目录下的README文件，找到这么一段话：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">[root@localhost redis-4.0.1]<span class="comment"># cat README.md</span></div><div class="line">......</div><div class="line">......</div><div class="line">Allocator</div><div class="line">---------</div><div class="line"></div><div class="line">Selecting a non-default memory allocator when building Redis is <span class="keyword">done</span> by setting</div><div class="line">the `MALLOC` environment variable. Redis is compiled and linked against libc</div><div class="line">malloc by default, with the exception of jemalloc being the default on Linux</div><div class="line">systems. This default was picked because jemalloc has proven to have fewer</div><div class="line">fragmentation problems than libc malloc.</div><div class="line"></div><div class="line">To force compiling against libc malloc, use:</div><div class="line"></div><div class="line">    % make MALLOC=libc</div><div class="line"></div><div class="line">To compile against jemalloc on Mac OS X systems, use:</div><div class="line"></div><div class="line">    % make MALLOC=jemalloc</div><div class="line"></div><div class="line">......</div><div class="line">......</div></pre></td></tr></table></figure></p>
<p>这是Redis在安装时关于内存分配器allocator的描述，如果指定了MALLOC这个环境变量，那么会用这个环境变量的去建立Redis。如果没有，那么就是用默认的分配器。Redis 2.4版本之后，默认使用jemalloc来做内存管理，因为jemalloc被证明解决fragmentation problems（内存碎片化问题）比libc更好。但是如果你又没有jemalloc而只有libc，当make出错时，你可以加这么一个参数即可 make MALLOC=libc。</p>
<p>如果我们就是想用jemalloc，那么安装jemalloc即可，该过程很简单，一般不会报错：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">[root@localhost opt]<span class="comment"># wget https://github.com/jemalloc/jemalloc/releases/download/5.0.1/jemalloc-5.0.1.tar.bz2</span></div><div class="line">[root@localhost opt]<span class="comment"># tar -xvf jemalloc-5.0.1.tar.bz2</span></div><div class="line">[root@localhost opt]<span class="comment"># cd jemalloc-5.0.1/</span></div><div class="line">[root@localhost jemalloc-5.0.1]<span class="comment"># ./configure --prefix=/usr/local/jemalloc</span></div><div class="line">[root@localhost jemalloc-5.0.1]<span class="comment"># make &amp;&amp; make install</span></div></pre></td></tr></table></figure></p>
<p>jemalloc安装完成后，可查看安装结果：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[root@localhost jemalloc-5.0.1]<span class="comment"># ll /usr/local/jemalloc/</span></div><div class="line">总用量 0</div><div class="line">drwxr-xr-x. 2 root root  62 8月  13 10:58 bin</div><div class="line">drwxr-xr-x. 3 root root  22 8月  13 10:58 include</div><div class="line">drwxr-xr-x. 3 root root 115 8月  13 10:58 lib</div><div class="line">drwxr-xr-x. 4 root root  28 8月  13 10:58 share</div></pre></td></tr></table></figure></p>
<p>解决完上边两个问题，再次对 Redis 进行编译，就不会报错了，因为我们打算采用jemalloc管理内存，所以编译时我们需要指定内存管理器：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@localhost jemalloc-5.0.1]<span class="comment"># cd ../redis-4.0.1/</span></div><div class="line">[root@localhost redis-4.0.1]<span class="comment"># make MALLOC=/usr/local/jemalloc/lib</span></div><div class="line">......</div><div class="line">......</div><div class="line">Hint: It<span class="string">'s a good idea to run '</span>make <span class="built_in">test</span><span class="string">' ;)</span></div><div class="line"></div><div class="line">make[1]: 离开目录“/opt/redis-4.0.1/src”</div></pre></td></tr></table></figure></p>
<ol>
<li><p>安装<br>编译完成后，执行 make install 进行安装，安装过程我没有发现什么错误：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">[root@localhost redis-4.0.1]<span class="comment"># cd src </span></div><div class="line">[root@localhost src]<span class="comment"># make install</span></div><div class="line"></div><div class="line">Hint: It<span class="string">'s a good idea to run '</span>make <span class="built_in">test</span><span class="string">' ;)</span></div><div class="line"></div><div class="line">    INSTALL install</div><div class="line">    INSTALL install</div><div class="line">    INSTALL install</div><div class="line">    INSTALL install</div><div class="line">    INSTALL install</div></pre></td></tr></table></figure>
</li>
<li><p>测试<br>安装完成后，我们一般还要对安装结果进行测试，测试的方式很简单，在安装结果中已经说明了，执行 make test 即可。不过在进行测试的过程中，我遇到了一个错误：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@localhost src]<span class="comment"># make test</span></div><div class="line">You need tcl 8.5 or newer <span class="keyword">in</span> order to run the Redis <span class="built_in">test</span></div><div class="line">make: *** [<span class="built_in">test</span>] 错误 1</div></pre></td></tr></table></figure>
</li>
</ol>
<p>这是由于tcl的版本低于8.5导致的，安装最新的tcl即可：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[root@localhost opt]<span class="comment"># wget https://sourceforge.net/projects/tcl/files/Tcl/8.6.7/tcl8.6.7-src.tar.gz</span></div><div class="line">[root@localhost opt]<span class="comment"># tar -zxvf tcl8.6.7-src.tar.gz  -C /usr/local/</span></div><div class="line">[root@localhost opt]<span class="comment"># cd /usr/local/tcl8.6.7/unix</span></div><div class="line">[root@localhost unix]<span class="comment"># ./configure</span></div><div class="line">[root@localhost unix]<span class="comment"># make</span></div><div class="line">[root@localhost unix]<span class="comment"># make install</span></div></pre></td></tr></table></figure></p>
<p>tcl安装完成后，再次进行测试，完美通过：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@localhost redis-4.0.1]<span class="comment"># make test</span></div><div class="line">......</div><div class="line">......</div><div class="line">\o/ All tests passed without errors!</div><div class="line"></div><div class="line">Cleanup: may take some time... OK</div><div class="line">make[1]: 离开目录“/opt/redis-4.0.1/src”</div></pre></td></tr></table></figure></p>
<ol>
<li>查看安装版本<br>其实安装完成后，版本看不看无所谓，反正我们自己肯定是知道自己安装的什么版本的。查看版本的命令是 redis-server -v：<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost redis-4.0.1]<span class="comment"># redis-server -v</span></div><div class="line">Redis server v=4.0.1 sha=00000000:0 malloc=libc bits=64 build=573071f5c48ca889</div></pre></td></tr></table></figure>
</li>
</ol>
<p>到现在，Redis就算安装完成了，很简单吧。</p>
<ol>
<li><p>服务端启动<br>执行 redis-server redis.conf，查看我们安装的Redis是否能正常启动，如果后面没有跟redis.conf则按照默认配置启动：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div></pre></td><td class="code"><pre><div class="line">[root@localhost redis-4.0.1]<span class="comment"># redis-server redis.conf</span></div><div class="line"></div><div class="line">27450:C 13 Aug 11:30:44.516 <span class="comment"># oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo</span></div><div class="line">27450:C 13 Aug 11:30:44.516 <span class="comment"># Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=27450, just started</span></div><div class="line">27450:C 13 Aug 11:30:44.516 <span class="comment"># Configuration loaded</span></div><div class="line">27450:M 13 Aug 11:30:44.517 * Increased maximum number of open files to 10032 (it was originally <span class="built_in">set</span> to 1024).</div><div class="line">                _._                                                  </div><div class="line">           _.-``__ <span class="string">''</span>-._                                             </div><div class="line">      _.-``    `.  `_.  <span class="string">''</span>-._           Redis 4.0.1 (00000000/0) 64 bit</div><div class="line">  .-`` .-```.  ```\/    _.,_ <span class="string">''</span>-._                                   </div><div class="line"> (    <span class="string">'      ,       .-`  | `,    )     Running in standalone mode</span></div><div class="line"> |`-._`-...-` __...-.``-._|'` _.-<span class="string">'|     Port: 6379</span></div><div class="line"> |    `-._   `._    /     _.-'    |     PID: 27450</div><div class="line">  `-._    `-._  `-./  _.-<span class="string">'    _.-'</span>                                   </div><div class="line"> |`-._`-._    `-.__.-<span class="string">'    _.-'</span>_.-<span class="string">'|                                  </span></div><div class="line"> |    `-._`-._        _.-'_.-<span class="string">'    |           http://redis.io        </span></div><div class="line">  `-._    `-._`-.__.-'_.-<span class="string">'    _.-'</span>                                   </div><div class="line"> |`-._`-._    `-.__.-<span class="string">'    _.-'</span>_.-<span class="string">'|                                  </span></div><div class="line"> |    `-._`-._        _.-'_.-<span class="string">'    |                                  </span></div><div class="line">  `-._    `-._`-.__.-'_.-<span class="string">'    _.-'</span>                                   </div><div class="line">      `-._    `-.__.-<span class="string">'    _.-'</span>                                       </div><div class="line">          `-._        _.-<span class="string">'                                           </span></div><div class="line">              `-.__.-'                                               </div><div class="line"></div><div class="line">27450:M 13 Aug 11:30:44.518 <span class="comment"># WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.</span></div><div class="line">27450:M 13 Aug 11:30:44.518 <span class="comment"># Server initialized</span></div><div class="line">27450:M 13 Aug 11:30:44.518 <span class="comment"># WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.</span></div><div class="line">27450:M 13 Aug 11:30:44.518 <span class="comment"># WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never &gt; /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.</span></div><div class="line">27450:M 13 Aug 11:30:44.518 * Ready to accept connections</div></pre></td></tr></table></figure>
</li>
<li><p>客户端连接<br>服务器端启动后，再用 redis-cli -h IP -p 端口号 命令查看客户端能否正常连接，连接进入后，使用info命令可以查看你所使用的内存管理器：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@localhost redis-4.0.1]<span class="comment"># redis-cli -h 127.0.0.1 -p 6379</span></div><div class="line">127.0.0.1:6379&gt; info</div></pre></td></tr></table></figure>
</li>
</ol>
<p>根据自己使用的内存管理器不同有如下两种结果:<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">mem_allocator:libc</div><div class="line">mem_allocator:jemalloc-4.0.3</div></pre></td></tr></table></figure></p>
<p>好了，Redis安装完了，下一讲，我们再说一下Redis的各个配置项。</p>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-08-16T11:32:36.000Z" itemprop="dateUpdated">2017-08-16 19:32:36</time>
</span><br>


        
        【转载请注明出处】<a href="/2017/08/16/20170816001/" target="_blank" rel="external">http://www.jkinn.com/2017/08/16/20170816001/</a>
        
    </div>
    <footer>
        <a href="http://www.jkinn.com">
            <img src="/img/avatar.jpg" alt="田埂↑の夢">
            田埂↑の夢
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Redis/">Redis</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.jkinn.com/2017/08/16/20170816001/&title=《Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1》 — JK客栈&pic=http://www.jkinn.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.jkinn.com/2017/08/16/20170816001/&title=《Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1》 — JK客栈&source=本站是 JK客栈 田埂上的梦（田埂↑の夢 王怀亮）的技术分享博客。内容涵盖Java后端技术、微服务架构、分布式架构、网络安全、运维开发等相关的研究与知识分享。" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://www.jkinn.com/2017/08/16/20170816001/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1》 — JK客栈&url=http://www.jkinn.com/2017/08/16/20170816001/&via=http://www.jkinn.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://www.jkinn.com/2017/08/16/20170816001/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/08/27/20170827001/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> 上一篇</div>
        <h5 class="title">Redis 探讨（二）： Redis 4.0.1 配置文件详解</h5>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/04/10/2017041001/" id="post-next" class="post-nav-link">
        <div class="tips">下一篇 <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h5 class="title">MySQL 深入探讨（一）： 阿里云 Linux CentOS 7.3 安装配置 JDK-1.8、MySQL-5.7</h5>
      </a>
    </div>
  
</nav>



    





<section class="comments" id="comments">
    <!-- UY BEGIN -->
    <div id="uyan_frame"></div>
    <script src="http://v2.uyan.cc/code/uyan.js?uid=2137675"></script>
    <!-- UY END -->
</section>










</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢您的支持
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/img/wechat.jpg" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check"
                data-wechat="/img/wechat.jpg" data-alipay="/img/alipay.jpg">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <!--<p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>-->
        </p>
    </div>
    <div class="bottom">
        <p><span>田埂↑の夢 &copy; 2015 - 2017</span>
            <span>
                
                <!--Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>-->
				田埂上的梦（王怀亮的博客）
            </span>
        </p>
    </div>
	


<!-- Baidu Push -->
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
<!-- End Baidu Push -->



</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.jkinn.com/2017/08/16/20170816001/&title=《Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1》 — JK客栈&pic=http://www.jkinn.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.jkinn.com/2017/08/16/20170816001/&title=《Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1》 — JK客栈&source=本站是 JK客栈 田埂上的梦（田埂↑の夢 王怀亮）的技术分享博客。内容涵盖Java后端技术、微服务架构、分布式架构、网络安全、运维开发等相关的研究与知识分享。" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://www.jkinn.com/2017/08/16/20170816001/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Redis 深入探讨（一）：Linux CentOS 7.3 安装 Redis 4.0.1》 — JK客栈&url=http://www.jkinn.com/2017/08/16/20170816001/&via=http://www.jkinn.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://www.jkinn.com/2017/08/16/20170816001/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


lazyScripts.push('//s95.cnzz.com/z_stat.php?id=1262549369&web_id=1262549369')

</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '欢迎回来';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
